package com.pureut.system.controller;

import java.util.Arrays;
import java.util.List;

import com.pureut.common.core.web.controller.BaseController;
import com.pureut.common.core.web.domain.AjaxResult;
import com.pureut.common.core.web.page.TableDataInfo;
import com.pureut.system.domain.vo.NonconformingProductReviewVo;
import com.pureut.system.service.INonconformingProductReviewService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;



/**
 * @Author: pureut
 * @Date: 2024-12-06 13:51:19
 * @Desc: 不合格品审Controller
 */
@RestController
@RequestMapping("/nonconformingProductReview")
public class NonconformingProductReviewController extends BaseController {

    /**
     * 不合格品审Service
     */
    @Autowired
    private INonconformingProductReviewService nonconformingProductReviewService;

    /**
     * 查询不合格品审列表
     * @param: params 参数列表
     * @return: Json工具类对象
     */
    //    @SaCheckPermission("nonconformingProductReview-list")
    @GetMapping("/list")
    public TableDataInfo list( NonconformingProductReviewVo nonconformingProductReviewVo) {
        startPage();
        return getDataTable(nonconformingProductReviewService.queryPage(nonconformingProductReviewVo));
    }



    /**
     * 获取不合格品审详细信息
     * @param: id 不合格品审主键
     * @return: Json工具类对象
     */
    //    @SaCheckPermission("nonconformingProductReview-query")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id) {
        return AjaxResult.success(nonconformingProductReviewService.getById(id));
    }

    /**
     * 新增不合格品审
     * @param: nonconformingProductReview 不合格品审对象
     * @return: Json工具类对象
     */
    //    @SaCheckPermission("nonconformingProductReview-add")
    @PostMapping
    public AjaxResult add(@RequestBody NonconformingProductReviewVo nonconformingProductReviewVo) {
        return toAjax(nonconformingProductReviewService.save(nonconformingProductReviewVo));
    }

    /**
     * 修改不合格品审
     * @param: nonconformingProductReview 不合格品审对象
     * @return: Json工具类对象
     */
    //    @SaCheckPermission("nonconformingProductReview-edit")
    @PutMapping
    public AjaxResult edit(@RequestBody NonconformingProductReviewVo nonconformingProductReviewVo) {
        return toAjax(nonconformingProductReviewService.updateById(nonconformingProductReviewVo));
    }

    /**
     * 删除不合格品审
     * @param: id 不合格品审主键
     * @return: Json工具类对象
     */
    //    @SaCheckPermission("nonconformingProductReview-remove")
    @DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids) {
        return toAjax(nonconformingProductReviewService.removeByIds(Arrays.asList(ids)));
    }
}
